/**
 *  promise 形式 showModal
 * @param {object} param0 参数
 */
export const showModal=({content})=>{
    return new Promise((resolve,reject)=>{
        wx.showModal({
            title: '提示',
            content: content,
            success: (result) => {
                resolve(result);
            },
            fail:(err)=>{
                reject(err);
            }
          });
    })
}

/**
 *  promise 形式 showToast
 * @param {object} param0 参数
 */
export const showToast=({title})=>{
    return new Promise((resolve,reject)=>{
        wx.showToast({
            title: title,
            icon: 'none',
            success: (result)=>{
                resolve(result);
            },
            fail:(err)=>{
                reject(err);
            }
          });
    })
}

export const uploadFile=({url,filePath})=>{
    const baseUrl = "http://localhost:8080";
    return new Promise((resolve,reject)=>{
        wx.uploadFile({
            url: baseUrl+url,
            filePath:filePath ,
            name:'file' ,
            success: (result)=>{
                resolve(result);
                
            },
            fail: (err)=>{
                reject(err);
            }
        });
    })
}

export const chooseImage=({})=>{
    return new Promise((resolve,reject)=>{
        wx.chooseImage({
            count: 1,
            sizeType: ['original','compressed'],
            sourceType: ['album','camera'],
            success: (result)=>{
                resolve(result.tempFilePaths);
            },
            fail: (err)=>{
                reject(err);
            }
        });
    })
}
export const showLoading=({title})=>{
    return new Promise((resolve,reject)=>{
        wx.showLoading({
            title:title,
            mask: true,
            success: (result)=>{
                resolve(result);
            },
            fail: (err)=>{
                reject(err);
            }
        });
    })
}
